<{include file="weixin/relay/block/header.html"}>
<link rel="stylesheet" type="text/css" href="%THEME%/weixin/relay/static/css/Coupon.css?201150408">
<body style="background:#005c5b;">
<div class="youhuiRelay">
	<img src="%THEME%/weixin/relay/static/img/youhuiRelay1.png" width="100%" height="" />
    <div class="youhuiRelay_infor">
        <div class="youhuiRelay_infor_posit">
            <div id="daojishi" rel="<{$detail.ltime-$time}>">00:00:00:00</div>
            <div class="youhuiRelay_infor_event">
                <div class="fl">
                	<p class="bt">时间</p>
                    <p><span class="time" id='time'><{$detail.time}></span>s</p>
                </div>
                <div class="fr">
                	<p class="bt">金钱</p>
                    <p><span id='qian'>0</span>元</p>
                </div>
                <div class="clear"></div>
            </div>
        </div>
        <div class="youhuiRelay_prompt_posit">
            <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td>剩余<i><{$detail.relay_num-$my_count}></i>次</td>
                </tr>
				 <tr>
                   <td>已经帮TA抢到<i><{$gold_all|default:0}></i>金币</td>
					</tr>
            </table>
        </div>
    	<img src="%THEME%/weixin/relay/static/img/youhuiRelay2.png" width="100%" height="" />
    </div>
    <div class="youhuiRelay_anniu">
    	<div class="youhuiRelay_anniu_posit">
       		<a href="#" class="fl anniu_fenx"><img src="%THEME%/weixin/relay/static/img/anniu_fenx.png" width="100%" height="" /></a>
        	<{if $detail.relay_num-$my_count<=0}>
            木了
            <{else}>
            	<a href="javascript:;" class="fr anniu_qiang"><img src="%THEME%/weixin/relay/static/img/anniu_qiang.png" width="100%" height="" /></a>
             <{/if}>
            
        </div>
    	<img src="%THEME%/weixin/relay/static/img/youhuiRelay3.png" width="100%" height="" />
    </div>
    <div class="youhuiRelay_tab">
    	<ul>
			<!-- <li class="youhuiRelay_tab_list youhuiRelay_tab_reply on"><a href="javascript:;">介绍</a></li>-->
			 <li class="youhuiRelay_tab_list "><a href="javascript:;">奖项设置</a></li>
    	    <li class="youhuiRelay_tab_list"><a href="javascript:;">TA抢到的</a></li>
            <li class="youhuiRelay_tab_list"><a href="javascript:;">好友接力</a></li> 
			<li class="youhuiRelay_tab_list"><a href="javascript:;">TOP10</a></li>
	    </ul>
        <div class="clear"></div>
    </div>
    <div class="youhuiRelay_list_box">
		 <div class="youhuiRelay_list" style="display:block;">
            
            <div class="shakePage_intro">
            	<p>奖项设置：</p>
                <{foreach $prizes as $k => $item}>
                <p><{$item.name}><{$item.num}>名，奖<{$item.title}>；</p>
                <{/foreach}> 
            </div>
           
        </div>
		
        <div class="youhuiRelay_list">
            <div class="youhuiRelay_mine">
            	<div class="youhuiRelay_mine_infor">
                	<div class="fl img"><img src="<{$my_sn_list.img}>" width="100" height="100" /></div>
                    <div class="wz">
                    	<p class="name"><{$my_sn_list.nick_name}>金币</p>
                        <p><{$my_sn_list.gold}>金币</p>
                        <p>玩了<{$my_sn_list.cishu}>次</p>
                    </div>
                    <div class="clear"></div>
                </div>
                <ul class="youhuiRelay_mine_list">
                	<{foreach $list_sn as $k => $item}>
                     <li><span class="fl">抢到金币</span><span class="fl long"><{$item.gold}>金币</span><span class="fr"><{$item.dateline|format}></span></li>
                    <{/foreach}>
                </ul>
            </div>
        </div>
        <div class="youhuiRelay_list">
            <div class="youhuiRelay_mine">
            	<{foreach $list_sn3 as $k => $item}>
                 <div class="youhuiRelay_mine_infor">
                	<div class="fl img"><img src="<{$item.img}>" width="100" height="100" /></div>
                    <div class="wz">
                    	<p class="name"><{$item.nickname}></p>
                        <p><{$item.gold}></p>
                        <p>玩了<{$item.cishu}>次</p>
                    </div>
                    <div class="clear"></div>
                </div>
                <{/foreach}>
            </div>
        </div>
		<div class="youhuiRelay_list">
        
                <ul>
                    <{foreach $sn_list as $k => $item}>
                    <li class="winRecord_list">
                        <div class="fl img"><img src="<{$item.img}>" width="100" height="100" /></div>
                        <div class="wz">
                            <p class="bt"><{$item.nickname}></p>
                            <p class="bt">（金币：<{$item.gold}>）</p>
                            <p class="greycl"><{$item.dateline|format}></p>
                        </div>
                        <div class="clear"></div>
                    </li>
                    <{/foreach}>
                </ul>
            </div>
            
            
        <div class="youhuiRelay_list">
        	
        </div>
        
    </div>
</div>

<script>
	$(document).ready(function(e) {	
		$('.youhuiRelay_tab_list').each(function (e) {
			$(this).click(function(){
				$('.youhuiRelay_tab_list').removeClass("on");
				$(this).addClass("on");
				$(".youhuiRelay_list_box .youhuiRelay_list").each(function(i){
					if(e==i){
						$(".youhuiRelay_list_box .youhuiRelay_list").hide();
						$(this).show();
					}
					else{
						$(this).hide();
					}
				});
			});
		});
	});
	$('.anniu_qiang').click(function(){
		<{if $error}>

			ErrorDialog();

		<{/if}>
		if($("#time").html() > 0){
			var hqian =  $("#qian").html();
			qian(hqian);
		}
		if(hqian == 0){
			var timer = setInterval(function () {	
				if($("#time").html() > 0){
					shijian($("#time").html());
				}
				
				if($("#time").html() == 0){
					var hqian =  $("#qian").html();
					var link = "<{link ctl='weixin/relay:sign2' arg0=$detail.relay_id arg1='#hqian#' arg2=$my_sn_list.sn_id http='base'}>";
					 $.getJSON(link.replace("#hqian#", hqian), function(ret){			
						if(ret.error >0){				
							ErrorDialog2(ret.message);			
						}else{			
							openSuccessDialog(ret.message);			
						}			
					});
					clearInterval(timer); 
				}
				
			}, 1000);
		}
		
	});
	
	function shijian(t) {
		t--;
		$("#time").html(t);
	}
	function qian(t) {
		var x = <{$detail.min_gold}>;
		var y = <{$detail.max_gold}>;
		var rand = parseInt(Math.random() * (x - y + 1) + y);
		var d = parseInt(t)+parseInt(rand);
		$("#qian").html(d);
		
	}
	
	function openSuccessDialog(msg){

		var successHtml = "<div class='common_dialog lqcg'>"

		+"<h6>恭喜您获得"+msg+"金币</h6>"

		+"<div class='tb'><a class='btn m_15 flex_1' href='###' onClick='on_devicemotion();'>确 定</a></div>"

		+"</div>"

		$.Dialog.open(successHtml);

	}

	function on_devicemotion(){

		location.reload();

	}

	

	function ErrorDialog2(msg){

		var successHtml = "<div class='common_dialog lqcg'>"

		+"<h6>"+msg+"</h6>"

		+"<div class='tb'><a class='btn m_15 flex_1' href='###' onClick='$.Dialog.close();'>确 定</a></div>"

		+"</div>"

		$.Dialog.open(successHtml);

	}
	
	
	function daojishi(id) {
		var t = Math.floor($("#" + id).attr('rel'));
		t--;
		var d = Math.floor(t / 60 / 60 / 24);
		var h = Math.floor(t / 60 / 60 % 24);
		var m = Math.floor(t / 60 % 60);
		var s = Math.floor(t % 60);
		$("#" + id).attr('rel', t);
		$("#" + id).html(d + '天' + h + '时' + m + '分' + s+'秒');
	}
	setInterval(function () {
		daojishi("daojishi");
	}, 1000);
</script>
</body>
</html>